#ifndef KYLINDAQCOMMON_H
#define KYLINDAQCOMMON_H
#include <QObject>
#include <QJsonObject>
#include <QVariant>
#if DEBUG
static constexpr const char* gs_confFileName= "debugKylinDaqConf.json";
static constexpr const char* gs_cacheFolderPath= "./";
static constexpr const char* gs_defaultConfFilePath = ":conf/conf/debugDefaultConf.json";
#else 
static constexpr const char* gs_confFileName= "kylinDaqConf.json";
static constexpr const char* gs_cacheFolderPath= "/var/cache/kylin-daq/";
static constexpr const char* gs_defaultConfFilePath = ":conf/conf/defaultConf.json";
#endif
static constexpr const char* gs_dataBaseName = "data.db";
static constexpr const char* gs_connectionName = "cacheManager";

static constexpr const char* gs_maxStr = "Max";
static constexpr const char* gs_defaultStr = "Default";
static constexpr const char* gs_minStr = "Min";
static constexpr const qlonglong gs_secToMsec = 1000;

static constexpr const char *gs_informationKey = "information";
static constexpr const char *gs_sourceKey = "source";
static constexpr const char *gs_packageNameKey = "packageName";
static constexpr const char *gs_messageTypeKey = "messageType";
static constexpr const char *gs_tidKey = "tid";
static constexpr const char *gs_parentTidKey = "parentTid";
static constexpr const char *gs_sourceVersionKey = "version";
static constexpr const char *gs_sourceVersionValue = "1.0.11";
/**
 * @brief 网络信息获取脚本
 */
static constexpr const char* gs_networkSh="network.sh";
/**
* @brief 网络信息获取脚本
*
*/
static constexpr const char* gs_shFilePath=":conf/sh/";
/**
 * @brief json对象中information对象的createTimeStamp键对应值格式
 * 
 */
static constexpr const char *gs_timeFormat = "yyyy-MM-dd HH:mm:ss.zzz";
/**
 * @brief json对象中information对象的createTimeStamp键
 * 
 */
static constexpr const char *gs_createTimeStampKey = "createTimeStamp";
//  time format
/**
 * @brief json对象中information对象的createTimeStamp键对应的时区
 * 
 */
static constexpr int32_t gs_timezone = 8*3600;// 时区为东八区

enum UploadState{
    UploadDisable = 0,
    UploadEnable = 1
};
enum FunctionState{
    FunctionSeccess = 0,
    FunctionFail = 1
};

template <typename A> A compareValue(const A inputValue,const A maxValue, const A minValue, const A defaultValue);
qlonglong secToMsec(qlonglong sec);
int getValidConfInt(const QJsonObject &conf ,const QJsonObject &defaultConf, const QString &key, qlonglong &value);
template <typename A> A compareValue(const A inputValue,const A maxValue, const A minValue, const A defaultValue)
{
    if(inputValue > maxValue || inputValue < minValue)
    {
        return defaultValue;
    }
    else
    {
        return inputValue;
    }

}
#endif
